<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="__CSS__/lib/normalize.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/mui-3.6.1.min.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/recharge.css" />
    <title>充值</title>
</head>

<body>
    <div class="top-bar">
        <div class="return" onclick="history.back()"></div>
        <div class="top-middle">充值</div>
        <div class="top-right"></div>
    </div>

    <div class="mui-input-row">
        <label>充值金额:</label>
    <input name="money" id="money" type="text" class="mui-input-clear" placeholder="请输入充值金额">
    </div>

    <ul class="list">
        <li class="rows title">使用第三方平台支付</li>

        <li class="rows">
            <div class="list-left"><span class="icon" style="background-image:url('__IMG__/wepay.png')"></span>微信支付</div>
            <div class="list-right"> <input id="radio0" type="radio" value="2" name="pay"/><label for="radio0" class="check icon"></label></div>
            <div class="mui-clearfix"></div>
        </li>
        <li class="rows">
            <div class="list-left"><span class="icon" style="background-image:url('__IMG__/alipay.png')"></span>支付宝支付</div>
            <div class="list-right"> <input id="radio1" type="radio" value="1" name="pay"/><label for="radio1" class="check icon"></label></div>
            <div class="mui-clearfix"></div>
        </li>
    </ul>

    <div class="button-simple gradient-color" onclick="showPay()">确认充值</div>
<script src="__JS__/jquery2.1.1.min.js"></script>
<script src="__JS__/layer.min.js"></script>
<script type="text/javascript">
function showPay() {
     var payType = $("input[name='pay']:checked").val();
     if (payType == null || payType == '' || payType == 'undefined') {
        layer.msg('请选择付款方式');
         return;
     }
    if(payType==1){
        layer.msg('支付宝支付正在建设中...');
        return;
    }else if(payType==2){

        if($('#isrepeat').val()==1){
            layer.msg('请不要重复提交');return;
        }

        var money=Number($('#money').val());

        if(isNaN(money)){
            layer.msg('非法金额');return;
        }
        if(money<=0){
            layer.msg('非法金额');return;
        }
          $.ajax({
              type: "POST",
              url: "{:U('Orders/touUp')}",
              data: {
                  money:money,
                  payType:2
              },
              dataType: "json",
              success: function(data){
                        layer.closeAll();
                        switch(data.status){
                            case 0: layer.msg('订单提交成功');
                            setTimeout(function(){
                                location.href="{:U('Confirm/onlinkPay')}";
                            },2000);
                            break;
                            case -1:
                              layer.msg('请先登录'); $('#isrepeat').val(0);location.href="{:U('Login/login')}";break;
                              break;
                            case -3:  layer.msg('请稍候重试'); $('#isrepeat').val(0);setTimeout(function(){location.reload([true])},1000);
                        }
                    }
              })
    }
}
</script>
</body>
</html>
